package Hot100.Tree;

import java.util.ArrayList;
import java.util.List;

public class isSymmetric {
    public static void main(String[] args) {
        int[] value = {1,2,2,2,-1,2};
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.insert(value);
        isSymmetric isSymmetric = new isSymmetric();

        System.out.println(isSymmetric.isSymmetric(binaryTree.root));
    }
    List<Integer> list1 = new ArrayList<>();

    List<Integer> list2 = new ArrayList<>();
    public boolean isSymmetric(TreeNode root) {
        if (root == null)
            return false;
        TreeNode pre = root;
        inorder(root);
        rioredr(pre);
        if(list1.equals(list2))
            return true;
        return false;
    }
    public void inorder(TreeNode root){
        if(root == null)
            return;
        inorder(root.left);
        list1.add(root.val);
        inorder(root.right);
    }
    public void rioredr(TreeNode root){
        if(root == null)
            return;
        rioredr(root.right);
        list2.add(root.val);
        rioredr(root.left);
    }
}
